﻿using System.Windows;
using Microsoft.WindowsAPICodePack.Shell;

namespace WpfMultitouchImageSearch
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            // Enable Glass
            //this.Loaded += (s, e) =>
            //{
            //    GlassEffectHelper.EnableGlassEffect(this);
            //};
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            SearchInLibraries(textBox1.Text);
        }

        private void SearchInLibraries(string searchtext)
        {
            SearchCondition searchCondition =
                SearchConditionFactory.ParseStructuredQuery(searchtext);

            ShellSearchFolder searchFolder =
                new ShellSearchFolder(
                    searchCondition,
                    (ShellContainer)KnownFolders.Libraries);

            try
            {
                _scatterView.ItemsSource = searchFolder;
            }
            catch
            {
                searchFolder.Dispose();
                searchFolder = null;
            }
        }
    }
}
